package com.qxgl.qxglt.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

import org.hibernate.annotations.GenericGenerator;

import lombok.Data;

@Data
@Entity
@Table
@GenericGenerator(name = "jpa-uuid",strategy = "uuid")
public class Modules {

    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @Column(length = 32)
    private String id;// 模块编号
    @Column(unique = true, nullable = false)
    private String name;// 模块名称
    @Column(length = 32)    
    private String parentId;// 父模块编号
    private String path;// 模块路径
    private String weight;// 权重

    // 模块相关角色
    @JsonIgnore
    @ManyToMany(cascade = CascadeType.REFRESH, mappedBy = "modulesList", fetch = FetchType.LAZY)
    private List<Roles> rolesList;
}